package morncloud.com.notes.database;

import android.provider.BaseColumns;

/**
 * Created by majoy on 2015/1/5.
 * define the base cloums and the base args
 */
public class Provider {
    public static final String DATABASE_NOTE = "notes";
    public static final int DATABASE_VERSION = 1;

    /**
     * define the base note cloumns
     */
    public static final class NoteDataCloumns implements BaseColumns {
        public final static String DATA = "DATA";
        public final static String CREATE_TIME = "CRATE_TIME";
        public final static String MOTIFIED_TIME = "MOTIFIED_TIME";
        public final static String ALERT_TIME = "ALERT_TIME";
    }
    public static final String TABLE_NOTES = "note";
    public static final String TABLE_NOTES_CREATE_SQL = "CREATE TABLE " + TABLE_NOTES +
            " ( " + NoteDataCloumns._ID + " INTEGER PRIMARY KEY ," +
            NoteDataCloumns.DATA + " CHAR NOT NULL DEFAULT null ," +
            NoteDataCloumns.CREATE_TIME + " TIMESTAMP NOT NULL DEFAULT  (datetime('now', 'localtime'))," +
            NoteDataCloumns.MOTIFIED_TIME + " TIMESTAMP ," +
            NoteDataCloumns.ALERT_TIME + " TIMESTAMP);";
    public static final String TABLE_NOTES_TRIGER = "CREATE TRIGGER update_or_insert AFTER  UPDATE OF " +
            NoteDataCloumns.DATA + "  ON " + TABLE_NOTES
            + " BEGIN UPDATE " + TABLE_NOTES +
            " SET " + NoteDataCloumns.MOTIFIED_TIME +
            " = (datetime('now', 'localtime')) WHERE " +
            NoteDataCloumns._ID + "=old." +
            NoteDataCloumns._ID + "; END;";

}
